import java.util.*;

class Node {
    int val;
    Node next;
    Node random;

    public Node(int val) {
        this.val = val;
        this.next = null;
        this.random = null;
    }
}
public class Test {
    /**
     * 前k个高频单词
     * @param words
     * @param k
     * @return
     *      1.遍历单词列表,确定每个单词次数
     *          第一次入map
     *          多次入map
     *      2.创建小根堆,同时进行遍历
     *          1.小根堆未满时
     *              频率相同时,按照大根堆进行存放
     *          2.小根堆已满
     *              根>后面元素->不处理
     *              根<后面元素->交换
     *              根==后面元素->根据字典序进行判断,小的交换,大不交换
     *      3.翻转堆
     *      4.遍历,存入列表
     *      5.返回列表
     */
    public List<String> topKFrequent(String[] words, int k) {
        Map<String,Integer> map = new HashMap<>();
        for(String s : words) {
            if(map.get(s) == null) {
                map.put(s,1);
            }else {
                int index = map.get(s);
                map.put(s,index + 1);
            }
        }

        PriorityQueue<Map.Entry<String,Integer>> priorityQueue
                = new PriorityQueue<>(new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                if(o1.getValue().compareTo(o2.getValue()) == 0) {
                    return o2.getKey().compareTo(o1.getKey());
                }
                return o1.getValue().compareTo(o2.getValue());
            }
        });

        for(Map.Entry<String,Integer> entry : map.entrySet()) {
            if(priorityQueue.size() < k) {
                priorityQueue.offer(entry);
            }else {
               if(priorityQueue.peek().getValue().compareTo(entry.getValue()) < 0) {
                        priorityQueue.poll();
                        priorityQueue.offer(entry);
                }else {
                   if(priorityQueue.peek().getValue().compareTo(entry.getValue()) == 0) {//判断次序
                       if (priorityQueue.peek().getKey().compareTo(entry.getKey()) > 0) {
                           priorityQueue.poll();
                           priorityQueue.offer(entry);
                       }
                   }
                }
            }
        }

        List<String> ret = new ArrayList<>();
        for(int i = 0;i < k;i++) {
            Map.Entry<String,Integer> entry = priorityQueue.poll();
            ret.add(entry.getKey());
        }
        Collections.reverse(ret);
        return ret;
    }
    /**
     旧键盘
     1.将打印结果放入set 将出现问题的键放入setBroken
     2.遍历键盘输入的字符串,set中存在则不放入,反之,判断setBroken是否存在,不存在,则add,并打印
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String a = in.nextLine();
            String b = in.nextLine();
            func(a,b);
        }
    }
    private static void func(String str1,String str2) {
        Set<Character> set = new HashSet<>();
        Set<Character> setBroken = new HashSet<>();
        for(char ch : str2.toUpperCase().toCharArray()) {
            set.add(ch);
        }

        for(char ch : str1.toUpperCase().toCharArray()) {
            if(!set.contains(ch) && !setBroken.contains(ch)) {
                System.out.print(ch);
                setBroken.add(ch);
            }
        }
    }
    /**
     随机链表的复制
     1.将原来链表进行遍历,并存入map使创建新链表
     2.再次遍历链表,找到相应的next 和random对新链表进行链接
     */
    public Node copyRandomList(Node head) {
        Map<Node,Node> map = new HashMap<>();

        Node cur = head;
        while(cur != null) {
            Node node = new Node(cur.val);
            map.put(cur,node);
            cur = cur.next;
        }

        cur = head;
        while(cur != null) {
            map.get(cur).next = map.get(cur.next);
            map.get(cur).random = map.get(cur.random);
            cur = cur.next;
        }

        return map.get(head);
    }
}
